<?php

class addtocart {

    function addcart() {
        $class_cart = 'btn btn-mini btn-success';
    }

}

function RandomActiveMail($length = 50) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, strlen($characters) - 1)];
    }
    return $randomString;
}

function EnscryptPassword($passwordEnscript) {
    return hash("sha512", md5(sha1(md5($passwordEnscript))));
}

class General {

    const USERNAME = 'info.neakporn@gmail.com';
    const PASSWORD = 'neakporn123';

}

function geturl() {
    $urlC = '';
    $url_a = '';
    $url_b = '';
    $request  = str_replace("/psarinternet/", "", $_SERVER['REQUEST_URI']); 
    $params = explode("/", $request);
    $url_a = $params[0];
    $url_b = (!empty($params[1])?$params[1]:'');
    $url_c = (!empty($params[2])?$params[2]:'');
    if(!empty($url_c)) {
        $params_b = explode("?", $url_c);
        if(in_array("product_detail.php", $params_b)) {
            $urlC = 'sigle';
        }
    } else {
        $urlC = '';
    }
    if (empty($url_a) && empty($url_b)) {
        $url = 'home';
    } elseif ($url_a == 'product' && $urlC!='sigle') {
        $url = 'archive';
    } elseif ($urlC=='sigle') {
        $url = 'single';
    } else {
        $url = $request;
    }
    return $url;
}

function getdistrict(){
	$id = $_GET['province_id'];
	echo $id;die;	
}
function random($length) {
		$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
		$size = strlen($chars);
		$str = '';
		for ($i = 0; $i < $length; $i++) {
			$str .= $chars[rand(0, $size - 1)];
		}
		return $str;
	}